﻿
using NUnit.Framework;

namespace funktionsplotter.compilertests
{
    [TestFixture]
    public class Compilierentest
    {

        [Test]
        public void Process_mit_Addition()
        {
            var sut = new compiler.Compilieren();
            var func = sut.Process("x+2");

            var erg = func(2);

            Assert.AreEqual(4, erg);
        }

        [Test]
        public void Process_mit_Subtraktion()
        {
            var sut = new compiler.Compilieren();
            var func = sut.Process("x-2");

            var erg = func(2);

            Assert.AreEqual(0, erg);
        }

        [Test]
        public void Process_mit_Multilikation()
        {
            var sut = new compiler.Compilieren();
            var func = sut.Process("x*2");

            var erg = func(2);

            Assert.AreEqual(4, erg);
        }

        [Test]
        public void Process_mit_Division()
        {
            var sut = new compiler.Compilieren();
            var func = sut.Process("x/2");

            var erg = func(2);

            Assert.AreEqual(1, erg);
        }

        [Test]
        public void Process_mit_Exponent()
        {
            var sut = new compiler.Compilieren();
            var func = sut.Process("System.Math.Pow(x,2) + x + 2");
         
            var erg = func(2);

            Assert.AreEqual(8, erg);
        }
        
        [Test]
        public void Process_Multiplikation_mit_Negativer_Zahlen()
        {
            var sut = new compiler.Compilieren();
            var func = sut.Process("x*-2");

            var erg = func(2);

            Assert.AreEqual(-4, erg);
        }

        [Test]
        public void Process_Punkt_vor_Strich()
        {
            var sut = new compiler.Compilieren();
            var func = sut.Process("x*2+10");

            var erg = func(2);

            Assert.AreEqual(14, erg);
        }

        [Test]
        public void Process_Leerzeichen_in_der_Formel()
        {
            var sut = new compiler.Compilieren();
            var func = sut.Process("x * 2 + 10");

            var erg = func(2);

            Assert.AreEqual(14, erg);
        }
    }
}
